<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link type="text/css" rel="stylesheet" href="layui/css/layui.css"/>
		<script type="text/javascript" src="layui/layui.js"></script>
	</head>
	<body>
		<form id="updateMessage" class="layui-form" action="">
		    <div class="layui-form-item">
				<label class="layui-form-label">
					<span style="color: red;">*</span>
					id:
				</label>
				<div class="layui-input-inline">
					<input type="text" id="messageId" name="messageId" 
						placeholder="请输入id" class="layui-input layui-bg-gray" readonly="readonly" />
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">
					<span style="color: red;">*</span>内容</label>
				<div class="layui-input-inline">
					<input  type="text" id="messageContent" name="messageContent" placeholder="内容"
						 class="layui-input layui-bg-gray" readonly="readonly" />
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">
					<span style="color: red;">*</span>状态</label>
				<div class="layui-input-inline">
				  		<input id="" type="radio" name="showHome" value="0" checked />已读
				              &nbsp;&nbsp;&nbsp;&nbsp;
				          <input id="" type="radio" name="showHome" value="1" />已回复
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">
					<span style="color: red;">*</span>注释</label>
				<div class="layui-input-inline">
					<input  type="text" id="messageNote" name="messageNote" placeholder="请输入注释"
						lay-verify = "required" class="layui-input">
				</div>
			</div>
			
			
			<div class="layui-form-item">
				<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="updateMessage">提交</button>
				<button type="reset" class="layui-btn" lay-submit>取消</button>
				</div>
			</div>
		</form>
		
		<script>
			layui.use(['form','layer'],function(){
				var form = layui.form,$ = layui.$,layer = layui.layer;
				form.on('submit(updateMessage)',function(data){
					//layer.msg("提交动作");
					// post把表单数据发送到服务器端
					// 使用序列化的时候 input的name属性当成参数名字  ，值是参数值
					var str = $("#updateMessage").serialize();
					$.post(
						"http://localhost:8080/fearless/MessageAdminServlet?req=messageUpdate",
						str,
						function(res){
							if(res.success){
						   	 //先得到当前iframe层的索引
							var index = parent.layer.getFrameIndex(window.name); 
							//再执行关闭 
							parent.layer.close(index);  
							//关闭父级页面的表格
							parent.layui.table.reload('table');
						   }else{
						   	layer.alert("修改失败");
						   }
						},
						"json"
					)
					
					return false;// 停留在这里
				})
				
			})
			
		</script>
		
	</body>
</html>
